<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }
      .div {
        width: 80px;
        margin: 20px auto;
        text-align: center;
        line-height: 30px;
      }
      #hd {
        width: 80px;
        height: 30px;
        background-color: #f1f1f1;
      }
      li {
        list-style: none;
        width: 80px;
        height: 30px;

        border: 1px solid #666;
        border-top: transparent;
      }
      ul {
        display: none;
      }
      li:hover {
        background-color: #f1f1f1;
      }
    </style>
  </head>
  <body>
    <div class="div">
      <div id="hd">做什么</div>
      <ul>
        <li>吃饭</li>
        <li>睡觉</li>
        <li>打豆豆</li>
      </ul>
    </div>
    <script>
      var hd = document.getElementById('hd')
      var la = document.querySelector('ul')
      var div = document.querySelector('.div')
      div.onmouseover = function () {
        hd.style.backgroundColor = '#999'
        la.style.display = 'block'
        // div.style.height = '120px'
      }
      //   ul.onmouseover = function () {
      //     hd.style.backgroundColor = '#999'
      //     la.style.display = 'block'
      //     div.style.height = '120px'
      //   }
      div.onmouseout = function () {
        hd.style.backgroundColor = '#f1f1f1'
        la.style.display = 'none'
      }
    </script>
  </body>
</html>
